/**
 * Simple validation script to test store functionality
 */

import { createPinia, setActivePinia } from 'pinia'
import { useHistoryStore } from './history'
import { useSearchStore } from './search'
import { useRecoveryStore } from './recovery'
import { useUIStore } from './ui'

// Setup Pinia
setActivePinia(createPinia())

// Test History Store
console.log('Testing History Store...')
const historyStore = useHistoryStore()
console.log('✓ History store initialized')
console.log('✓ Initial state:', {
  versions: historyStore.versions.length,
  currentVersion: historyStore.currentVersion,
  hasVersions: historyStore.hasVersions
})

// Test Search Store
console.log('\nTesting Search Store...')
const searchStore = useSearchStore()
console.log('✓ Search store initialized')
console.log('✓ Initial state:', {
  query: searchStore.query,
  searchType: searchStore.searchType,
  hasResults: searchStore.hasResults
})

// Test Recovery Store
console.log('\nTesting Recovery Store...')
const recoveryStore = useRecoveryStore()
console.log('✓ Recovery store initialized')
console.log('✓ Initial state:', {
  queueLength: recoveryStore.recoveryQueue.length,
  isRecovering: recoveryStore.isRecovering,
  hasQueuedTasks: recoveryStore.hasQueuedTasks
})

// Test UI Store
console.log('\nTesting UI Store...')
const uiStore = useUIStore()
console.log('✓ UI store initialized')
console.log('✓ Initial state:', {
  theme: uiStore.theme,
  currentView: uiStore.currentView,
  hasNotifications: uiStore.hasNotifications
})

// Test some basic functionality
console.log('\nTesting basic functionality...')

// Test UI notifications
uiStore.showSuccess('Test Success', 'This is a test notification')
console.log('✓ Notification created:', uiStore.notifications.length)

// Test search query
searchStore.setQuery('test query')
console.log('✓ Search query set:', searchStore.query)

// Test recovery task
const testTask = recoveryStore.createRecoveryTask('v1', 'f1', 'original', 'target')
recoveryStore.addToQueue(testTask)
console.log('✓ Recovery task added:', recoveryStore.recoveryQueue.length)

// Test history file selection
historyStore.toggleFileSelection('test-file')
console.log('✓ File selection toggled:', historyStore.selectedFiles.length)

console.log('\n✅ All stores validated successfully!')

export { historyStore, searchStore, recoveryStore, uiStore }